<template>
  <div class="box">
    <dl v-for="item in list" :key="item.id" @click="handleClick(item)">
      <dt>
        <img :src="item.imgurl" alt="">
        <div class="coverContent" v-if="item.status === '3'">
          已下架
        </div>
      </dt>
      <dd>
        <p>
          <img :src="item.logo" alt="">
          {{item.mch_name}}
        </p>
        <p>{{item.product_title}}</p>
        <p>{{item.price}}</p>
      </dd>
    </dl>
  </div>
</template>

<script>
import Event from '@/assets/js/event'
import mixin from '@/assets/js/scrollTop'
export default {
  name: 'hotRecommendList',
  mixins: [mixin],
  props: ['list', 'navListId'],
  data () {
    return {
      title: '家居家纺'
    }
  },
  mounted () {
  },
  methods: {
    handleClick (item) {
      console.log(this.navListId)
      this.$store.commit('changePage', 'ProductDetails')
      if (this.$store.state.BreadcrumbTitle === '热销') {
        this.title = '热销'
      } else if (this.$store.state.BreadcrumbTitle === '新品') {
        this.title = '新品'
      } else if (this.navListId === '8') {
        this.title = '家居家纺'
      } else if (this.navListId === '2') {
        this.title = '5G手机'
      } else if (this.navListId === '309') {
        this.title = '精美箱包'
      } else if (this.navListId === '3') {
        this.title = '流行服饰'
      } else if (this.navListId === '11') {
        this.title = '家用电器'
      } else if (this.navListId === '1') {
        this.title = '美妆护理'
      } else if (this.navListId === '4') {
        this.title = '日用百货'
      }
      this.$store.commit('sendProductDetails', { products: item, title: this.title })
      Event.$emit('toProduct')
      this.scrolltotop()
    }
  }
}
</script>

<style scoped lang="scss">
  .box {
    overflow: hidden;
    width: 100%;
    margin: 0 auto;
    /*background-color: #f0ff76;*/
    dl {
      display: block;
      position: relative;
      width: 311.4px;
      height: 403px;
      /*border: 1px solid rgba(211, 211, 211, 0.76);*/
      /*这里父元素必须清楚浮动，不然会布局塌陷*/
      float: left;
      margin: 18px 15px 8px 0;
      cursor: pointer;
      &:nth-child(4n) {
        margin-right: 0;
      }
      &:hover {
        box-shadow: rgb(228, 228, 228) 0px 0px 5px 2px;
        dd {
          background-color: rgb(238, 238, 238);
        }
      }
    }
    dt {
      width: 100%;
      height: 301px;
      position: relative;
      top: 0;
      background-color: #ffffff;
      .coverContent {
        font-size: 18px;
        color: #ffffff;
        line-height: 200px;
        text-align: center;
        position: absolute;
        width: 200px;
        height: 200px;
        top: 0;
        bottom: 0;
        left: 0;
        right: 0;
        display: block;
        margin: auto;
        border-radius: 200px;
        background-color: rgba(0, 0, 0, 0.4);
      }
      img {
        display: block;
        width: 100%;
        height: 305px;
        margin: auto;
      }
    }
    dd {
      width: 100%;
      text-align: center;
      height: 102px;
      overflow: hidden;
      display: flex;
      flex-direction: column;
      justify-content: center;
      align-items: center;
      p {
        width: 100%;
        height: 18px;
        margin-bottom: 3px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        &:nth-child(2) {
          color: #020202;
          font-weight: bold;
        }
        &:nth-child(3) {
          color: red;
        }
      }
      img {
        width: 19px;
        height: 18px;
        margin-right: 3px;
      }
    }
  }
</style>
